package com.xavier.dong.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * @author XavierDong
 **/
public class NIOFileChannel04 {

    public static void main(String[] args) {

        try (FileInputStream fileInputStream = new FileInputStream("/Users/xavierdong/Documents/HP资料/架构图.jpeg");
             FileOutputStream fileOutputStream = new FileOutputStream("a2.jpg")) {

            FileChannel source = fileInputStream.getChannel();

            FileChannel target = fileOutputStream.getChannel();

// 拷贝
            target.transferFrom(source, 0, source.size());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
